import { createBrowserRouter, Navigate } from 'react-router-dom'
import { lazy } from 'react'
import Main from '../pages/main'
import Home from '../pages/home'
import Mall from '../pages/mall'
import User from '../pages/user'
import PageOne from '../pages/other/pageOne'
import PageTwo from '../pages/other/pageTwo'
import Xiangqing from '../pages/mall/xiangqing'
import Detail from '../pages/mall/detail'
const PageThree=lazy(()=>import('../pages/other/pageThree'))
const routes = [
    {
        path: '/',
        Component: Main,
        children: [
            // 重定向
            {
                path: '/',
                element: <Navigate to='home' replace />
            },
            {
                path: 'home',
                Component: Home
            },
            {
                path: 'mall',
                element:<Mall/>,
                children:[
                   {    
                        index:true,
                        element:<Xiangqing/>
                    },
                   {
                        path:'detail',
                        element:<Detail/>
                    },
                ]
            },
            {
                path: 'user',
                Component: User,
            },
            {
                path: 'other',
                children: [
                    {
                        path: 'pageone',
                        Component: PageOne
                    },
                    {
                        path: 'pagetwo',
                        Component: PageTwo
                    },
                    {
                        path:'pagethree',
                        element:<PageThree/>
                    }
                ]
            },
            // {
            //     path:'/mall/xq',
            //     element:<Xiangqing/>

            // }
            
           
        ],
       
    },
   
]
export default createBrowserRouter(routes)